#define _CRT_SECURE_NO_WARNINGS
//
// Created by 猎人猪 on 2023/2/26.
//

#include "common.h"
#include <stdio.h>

void print_hex(unsigned char* data, int length)
{
    printf("\n");
    for(int i=0;i<length;++i)
    {
        printf("%02x",data[i]);
    }
    printf("\n");
}

void calculate_sk(unsigned char* c3,unsigned char* c4,unsigned char* sk)
{
    for(int i=0;i<KEY_LENGTH_BYTES;++i)
    {
        *(sk+i)=*(c3+i) ^ *(c4+i);
    }
}

int arrayToStr(unsigned char* buf, unsigned int buflen, char* out)
{
    char strBuf[33] = { 0 };
    char pbuf[32];
    int i;
    for (i = 0; i < buflen; i++)
    {
        sprintf(pbuf, "%02X", buf[i]);
        strncat(strBuf, pbuf, 2);
    }
    strncpy(out, strBuf, buflen * 2);
    printf("out = %s\n", out);
    return buflen * 2;
}